package emuns

import "net/http"

type Result struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

var (
	TokenEmptyErr = Result{http.StatusUnauthorized, "凭据不能为空", nil}
	AuthorizedErr = Result{http.StatusUnauthorized, "错误的凭据", nil}
)

func Success(data any) *Result {
	return &Result{http.StatusOK, "操作成功", data}
}
func (r *Result) Success(info string) *Result {
	return &Result{http.StatusOK, info, r.Data}
}
func Error() *Result {
	return &Result{http.StatusInternalServerError, "操作失败", nil}
}
func (r *Result) Error(info string) *Result {
	return &Result{http.StatusInternalServerError, info, nil}
}
